package com.wxq.cart.controller;

import com.wxq.cart.service.StudentRepository;
import com.wxq.cart.vo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Optional;

/**
 * @author Jim
 * @date 1:03 上午 2022/4/25
 * @description
 * @email:huwmz04153277@126.com
 */

@RestController
public class MongoTestController {

    @Autowired

    StudentRepository studentRepository;


    @GetMapping("/addMongo")

    public String addMongo() {

        Student student = new Student();

        student.setId(String.valueOf(System.currentTimeMillis() / 10000));

        student.setName(student.getId() + "OKK");

        studentRepository.save(student);
        Example example=Example.of(student);
        Optional one = studentRepository.findOne(example);
        System.err.println(one.get());

        return student.getName();


    }
}